<!-- 数据分析 -->
<template>
  <div class="newTest">
    <div class="title" style="border-bottom: 1px solid #eee;">
      数据分析
      <el-radio-group
        v-model="showType"
        size="small"
        @change="showTypeChange"
        style="margin-left: 12px;"
      >
        <el-radio-button label="因子超标时段分析" v-if="!userInfo.roles.includes('manager')"></el-radio-button>
        <el-radio-button label="水质分析" v-if="!userInfo.roles.includes('manager')"></el-radio-button>
        <el-radio-button label="日均值分析"></el-radio-button>
      </el-radio-group>
    </div>

    <!-- 因子超标时段分析 -->
    <div class="dataChartCnt" v-if="showType === '因子超标时段分析'">
      <div class="searchBox">
        <el-form
          label-position="top"
          inline
          :model="searchForm"
          size="mini"
          style="max-height: 100px;"
        >
          <el-form-item>
            <p slot="label" class="miniLabel">站点选择</p>
            <el-select v-model="searchForm.waterstation" placeholder="请选择站点">
              <el-option v-for="item in stationList" :key="item" :label="item" :value="item"></el-option>
            </el-select>
          </el-form-item>
          <el-form-item>
            <p slot="label" class="miniLabel">时间段</p>
            <el-date-picker
              v-model="timePicker"
              type="daterange"
              value-format="yyyy-MM-dd"
              range-separator="至"
              start-placeholder="开始日期"
              end-placeholder="结束日期"
              :picker-options="pickerOptions"
            ></el-date-picker>
          </el-form-item>
          <el-form-item>
            <p class="searchBtns">
              <el-button type="success" class="greenBtn" @click="getChartsData">确定</el-button>
            </p>
          </el-form-item>
        </el-form>
      </div>
      <div class="dataChartBox">
        <div class="chart" v-for="(option, index) in waterPerlodList" :key="index">
          <el-button size="mini" class="openchart" @click="openDetailChart(option)">
            <i class="iconfont iconquanping"></i>
          </el-button>
          <lineChart :option="option" :isShow="option.show" style="display: flex; flex-grow:1"></lineChart>
        </div>
        <p class="noData" v-show="isNoData">暂无数据</p>
      </div>
    </div>

    <!-- 全屏弹出框 -->
    <el-dialog
      :visible.sync="detailChartVisible"
      width="80%"
      custom-class="historyChart"
      append-to-body
    >
      <div class="deatailChartCnt">
        <div class="deatailChart" id="deatailChart"></div>
      </div>
    </el-dialog>

    <!-- 水质分析 -->
    <div class="dataChartCnt" v-if="showType === '水质分析'">
      <div class="searchBox">
        <el-form
          label-position="top"
          inline
          :model="searchForm"
          size="mini"
          style="max-height: 100px;"
        >
          <el-form-item>
            <p slot="label" class="miniLabel">时间段</p>
            <el-date-picker
              v-model="waterQualityDatePicker"
              type="daterange"
              range-separator="至"
              start-placeholder="开始日期"
              end-placeholder="结束日期"
              value-format="yyyy-MM-dd"
              :picker-options="pickerOptions"
            ></el-date-picker>
          </el-form-item>
          <el-form-item>
            <p class="searchBtns">
              <el-button type="success" class="greenBtn" @click="getChartsData">确定</el-button>
            </p>
          </el-form-item>
        </el-form>
      </div>
      <div class="evaluation">
        <div class="evaluationCard">
          <div class="cardTit">
            <span>水质达标情况分析</span>
          </div>
          <div class="chartBox" v-loading="waterLoading">
            <div id="qualityAnalysisChart" class="chartBox"></div>
            <!-- <div id="main" style="width: 600px;height:400px;"></div> -->
            <!-- <charts :option="qualityAnalysisChart"></charts> -->
          </div>
        </div>
        <div class="evaluationCard">
          <div class="cardTit">
            <span>超标站点数</span>
          </div>
          <div class="chartBox" v-loading="factorLoading">
            <!-- <charts :option="qualityExceedNumChart"></charts> -->
            <div id="overStandChart" class="chartBox"></div>
          </div>
        </div>
      </div>
    </div>

    <!-- 日均值分析 -->
    <div class="dataChartCnt" v-if="showType === '日均值分析'" v-loading="hisLoading">
      <div class="searchBox">
        <el-form
          label-position="top"
          inline
          :model="searchForm"
          size="mini"
          style="max-height: 100px;"
        >
          <el-form-item>
            <p slot="label" class="miniLabel">水站名称</p>
            <el-select v-model="searchForm.watersmeantation" placeholder="请选择水站名称">
              <p v-for="(item, index) of stationList" :key="index">
                <el-option :label="item" :value="item" se></el-option>
              </p>
            </el-select>
          </el-form-item>
          <el-form-item>
            <p slot="label" class="miniLabel">时间段</p>
            <el-date-picker
              v-model="timePickerDay"
              type="daterange"
              value-format="yyyy-MM-dd"
              range-separator="至"
              start-placeholder="开始日期"
              end-placeholder="结束日期"
              :picker-options="pickerOptions"
            ></el-date-picker>
          </el-form-item>
          <!-- <el-form-item>
            <p slot="label" class="miniLabel">开始时间</p>
            <el-date-picker
              v-model="searchForm.starttime"
              placeholder="选择开始时间"
              :clearable="false"
              value-format="yyyy-MM-dd"
              :picker-options="pickerOptions"
            ></el-date-picker>
          </el-form-item>
          <el-form-item>
            <p slot="label" class="miniLabel">结束时间</p>
            <el-date-picker
              v-model="searchForm.lasttime"
              placeholder="选择结束时间"
              :clearable="false"
              value-format="yyyy-MM-dd"
              :picker-options="pickerOptions"
            ></el-date-picker>
          </el-form-item>-->

          <el-form-item>
            <p class="searchBtns">
              <el-button type="success" class="greenBtn" @click="getChartsData">筛选</el-button>
              <el-button type="success" class="greenBtn" @click="openExportOption">导出</el-button>
            </p>
          </el-form-item>
        </el-form>
        <div class="tubiao showType">
          <el-radio-group
            v-model="mintype"
            size="small"
            @change="showTypeAction"
            style="margin-left: 12px;"
          >
            <el-radio-button label="图表"></el-radio-button>
            <el-radio-button label="表格"></el-radio-button>
          </el-radio-group>
        </div>
      </div>

      <!-- <div v-show="mintype === '图表'" class="dataChartCnt">
        <div class="dataChartBox">
          <div
            class="chart"
            v-for="(option,index) in lineOptions"
            :key="index"
            v-show="option.show"
          >
            <el-button size="mini" class="openchart" @click="openDetailChart(option)">
              <i class="iconfont iconquanping"></i>
            </el-button>
            <lineChart :option="option" :isShow="option.show"></lineChart>
          </div>
          <p class="noData" v-show="!isMeanNoData">暂无数据</p>
        </div>
      </div> -->
      <div class="dataChartCnt" v-if="mintype === '图表'">
        <div class="dataChartBox">
          <div
            class="chart"
            v-for="(option, index) in lineOptions"
            :key="index"
            v-show="option.show"
          >
            <el-button size="mini" class="openchart" @click="openDetailChart(option)">
              <i class="iconfont iconquanping"></i>
            </el-button>
            <lineChart :option="option" :isShow="option.show"></lineChart>
          </div>
          <p class="noData" v-show="!isMeanNoData">暂无数据</p>
        </div>
      </div>
      <div class="tableList" v-show="mintype === '表格'">
        <tableList
          :hisDataList="avgDatas"
          :factorField="factorField"
          :factorStatus="factorStatus"
          :type="'day'"
          :standard="standard"
        ></tableList>
        <v-paging @setCurrent="setPage" @setCurren="setNum" :total="totalpage" />
      </div>
    </div>
    <!-- 导出表格配置 -->
    <el-dialog :visible.sync="exportExcelVisible" append-to-body>
      <div slot="title">
        <p>导出表格</p>
      </div>
      <el-form :model="searchForm" size="mini" label-width="90px">
        <el-row>
          <el-form-item label="水站：">
            <el-select
              v-model="searchForm.watersmeantation"
              placeholder="请选择需要导出的水站"
              style="width: 80%"
            >
              <el-option
                v-for="station in stationList"
                :key="station"
                :label="station"
                :value="station"
              ></el-option>
            </el-select>
          </el-form-item>
        </el-row>
        <el-row>
          <el-form-item>
            <p slot="label" class="miniLabel">时间段</p>
            <el-date-picker
              v-model="timePickerDay"
              type="daterange"
              value-format="yyyy-MM-dd"
              range-separator="至"
              start-placeholder="开始日期"
              end-placeholder="结束日期"
              :picker-options="pickerOptions"
            ></el-date-picker>
          </el-form-item>
          <!-- <el-form-item label="开始时间：">
            <el-date-picker
              v-model="exportOption.starttime"
              type="datetime"
              placeholder="选择开始时间"
              :clearable="false"
              value-format="yyyy-MM-dd HH:00:00"
            ></el-date-picker>
          </el-form-item>
          <el-form-item label="结束时间：">
            <el-date-picker
              v-model="exportOption.lasttime"
              type="datetime"
              placeholder="选择结束时间"
              :clearable="false"
              value-format="yyyy-MM-dd HH:00:00"
            ></el-date-picker>
          </el-form-item>-->
        </el-row>
        <el-form-item label>
          <el-button type="primary" @click="exportExcel">导出</el-button>
        </el-form-item>
      </el-form>
    </el-dialog>
  </div>
</template>

<script>
import { mapGetters, mapActions } from "vuex";
import lineChart from "../components/charts.vue";
import common from "@/plugins/common";
// import standard from "../plugins/standard.js";
import myPaging from "@/components/myPaging.vue";
import tableList from "@/components/tableList.vue";
import { waterPerlod, waterRate, meanRate, meanRateDownload } from "@/http/api";
export default {
  data() {
    return {
      timePicker: [],
      timePickerDay: [],
      showType: "因子超标时段分析",
      searchForm: {
        waterstation: "",
        // starttime: "",
        // lasttime: "",
        isExcel: "no",
        watersmeantation: "",
      },
      factor: {},
      water: {},
      waterLoading: false,
      factorLoading: false,
      mintype: "图表", //表格图表切换
      waterPerlodList: {},
      lineOptions: {},
      detailChartVisible: false,
      detailChart: null,
      // 水质
      qualityAnalysisOption: {},

      waterQuality: {},
      qualityAnalysisSearch: "259200000",
      loading: false,
      qualityAnalysisChart: {}, //水环境质量排名 - 达标率超标率对比
      qualityExceedNumChart: {}, //水环境质量排名 - 超标站点数
      qualityAnalysisChartOption: {}, //水环境质量排名 - 达标率超标率对比设置
      factorTableVisible: false,
      allFactorResult: [],
      factorTableLoading: false,
      factorTable: [],
      factorTableType: null,
      curFactor: null,
      curStation: null,
      pieChartLoading: false,
      waterQualityDatePicker: [],
      hisLoading: false,
      standard: {},
      // standard,
      //日均分析值
      avgDatas: [],
      searchResult: {},
      factorField: [],
      factorStatus: {},
      currentPage: 1,
      totalpage: 0,
      pageSize: 12,
      isMeanNoData: true,
      exportExcelVisible: false,
      waterfactorField: {},
      pickerOptions: {
        disabledDate: (time) => {
          return time.getTime() > Date.now();
        },
      },
    };
  },
  created() {
    this.searchForm.waterstation = this.stationList
      ? this.stationList[0]
      : "沙江4#";
    this.searchForm.watersmeantation = this.stationList
      ? this.stationList[0]
      : "沙江4#";
    this.timePickerDay = [
      common.changeDateToString(new Date(new Date().getTime() - 518400000)),
      common.changeDateToString(new Date()),
    ];
    this.timePicker[0] = this.timePickerDay[0];
    this.timePicker[1] = this.timePickerDay[1];
    this.waterQualityDatePicker[0] = this.timePickerDay[0];
    this.waterQualityDatePicker[1] = this.timePickerDay[1];
    let roles = ["manager", "environmentalDirector"];
    if (roles.includes(this.userInfo.roles[0])) {
      this.showType = "日均值分析";
    } else {
      this.showType = "因子超标时段分析";
    }
    this.getChartsData();
  },
  components: {
    lineChart,
    tableList,
  },
  computed: {
    ...mapGetters({
      stationList: "getStationList",
      historyHasCod: "getHistoryHasCod",
      userInfo: "getUserInfo",
      //水质分析
      times: "getTimes",
    }),
    isNoData() {
      if (!this.waterPerlodList) return;
      return !Object.values(this.waterPerlodList)
        .map((v) => v.show)
        .includes(true);
    },
  },
  methods: {
    /**
     * 选项切换
     */
    showTypeChange() {
      //search 默认值操作
      this.getChartsData();
    },
    // 筛选获取各类型初始值
    async getChartsData() {
      if (this.showType == "因子超标时段分析") {
        let params = {
          starttime: this.timePicker[0] + " 00:00:00",
          lasttime: this.timePicker[1] + " 23:59:59",
          waterstation: this.searchForm.waterstation,
        };
        await waterPerlod(params).then((res) => {
          this.waterPerlodList = res.data;
          this.waterfactorField = res.factorField;
          this.initCharts();
        });
      } else if (this.showType == "水质分析") {
        let params = {
          startTime: this.waterQualityDatePicker[0] + " 00:00:00",
          endTime: this.waterQualityDatePicker[1] + " 23:59:59",
        };
        this.waterLoading = true;
        this.factorLoading = true;
        await waterRate(params).then((res) => {
          this.water = res.data.water;
          res.data.factorMessage.forEach((item) => {
            if (Object.keys(res.data.factor).includes(item.name)) {
              this.factor[item.name] = res.data.factor[item.name];
            }
          });
          this.waterLoading = false;
          this.factorLoading = false;
          this.initQualityAnalysisOption();
          this.initOverStandOption();
        });
      } else {
        this.showTypeAction();
      }
    },
    /**
     * 因子超标时段分析
     */
    initCharts() {
      let optionColor = {
        pH: "#A3A6F6",
        cod: "#F47FC1",
        ammoniaNitrogen: "#5BB0F0",
        phosphorus: "#FF8282",
        nitrogen: "#F0D65B",
        nickel: "#67EBAB",
        cuprum: "#F09C5B",
        chromium: "#5DD3EC",
        prussiate: "#D4A3F6",
        zinc: "#5BF0E6",
      };
      this.$nextTick(() => {
        for (let i in this.waterPerlodList) {
          this.waterPerlodList[i] = {
            xAxis: {
              type: "category",
              data: Object.keys(this.waterPerlodList[i]).map(
                (item) => item + ":00"
              ),
              name: "时间",
            },
            yAxis: {
              type: "value",
              name: "超标次数/次",
              minInterval: 1,
            },
            tooltip: {
              trigger: "axis",
              axisPointer: {
                // 坐标轴指示器，坐标轴触发有效
                type: "shadow", // 默认为直线，可选为：'line' | 'shadow'
              },
            },
            series: [
              {
                name: "超标次数",
                type: "bar",
                data: Object.values(this.waterPerlodList[i]).map(
                  (item) => item
                ),
                barWidth: 16,
                itemStyle: {
                  color: optionColor[i],
                },
              },
            ],
            show: true,
            title: {
              left: "center",
              text: this.waterfactorField[i],
              textStyle: {
                fontSize: 14,
              },
            },
          };
        }
      });
    },

    /**
     *  水质分析
     */
    //超标站点数
    initOverStandOption() {
      let overStandChart = this.$echarts.init(
        document.getElementById("overStandChart")
      );
      let qualityExceedNumOption = {
        color: ["#ef9887"],
        grid: {
          top: 40,
          left: 40,
          right: 10,
          bottom: 70,
        },
        tooltip: {
          trigger: "axis",
          axisPointer: {
            // 坐标轴指示器，坐标轴触发有效
            type: "shadow", // 默认为直线，可选为：'line' | 'shadow'
          },
        },
        xAxis: [
          {
            type: "category",
            axisTick: {
              show: false,
            },
            axisLabel: {
              formatter: (value) => value.split("").join("\n"),
            },
            data: Object.keys(this.factor).map((item) => item),
          },
        ],
        yAxis: [
          {
            name: "个",
            type: "value",
            // max: 8,
            axisTick: {
              show: false,
            },
          },
        ],
        series: [
          {
            name: "超标站点数",
            type: "bar",
            barWidth: 20,
            data: Object.values(this.factor).map((item) => item.length),
          },
        ],
      };
      overStandChart.setOption(qualityExceedNumOption);
    },
    //初始化水质达标情况分析
    initQualityAnalysisOption() {
      let myChart = this.$echarts.init(
        document.getElementById("qualityAnalysisChart")
      );

      // 指定图表的配置项和数据
      var option = {
        color: ["#ff6341", "#2ac4e0"],
        grid: {
          top: 20,
          left: 40,
          right: 10,
          bottom: 80,
        },
        tooltip: {
          trigger: "axis",
          // formatter: '{b}<br />{a0}: {c0}%<br />{a1}: {c1}%',
          formatter: (params) => {
            let str = `${params[0].name}<br />`;
            for (let i = 0; i < params.length; i++) {
              str += `<span style="display:inline-block;vertical-align: middle;border-radius: 50%;width:12px;height:12px;background: ${
                params[i].color.colorStops[0].color
              };"></span> ${params[i].seriesName}: ${params[i].value.toFixed(
                2
              )} % <br />`;
            }
            return str;
          },
          axisPointer: {
            // 坐标轴指示器，坐标轴触发有效
            type: "shadow", // 默认为直线，可选为：'line' | 'shadow'
          },
        },
        xAxis: [
          {
            type: "category",
            data: Object.keys(this.water).map((item) => item),
            axisTick: {
              show: false,
            },
            axisLabel: {
              formatter: (value) => value.split("").join("\n"),
            },
          },
        ],
        yAxis: [
          {
            type: "value",
            max: 100,
            axisLabel: {
              formatter: "{value}%",
            },
            axisTick: {
              show: false,
            },
          },
        ],
        series: [
          {
            name: "达标率",
            type: "bar",
            barWidth: 20,
            stack: "1",
            data: Object.values(this.water).map((item) => item.up * 100),
            itemStyle: {
              normal: {
                color: new this.$echarts.graphic.LinearGradient(0, 1, 1, 0, [
                  {
                    offset: 0,
                    color: "#5BB0F0",
                  },
                  {
                    offset: 1,
                    color: "#5DD3EC",
                  },
                ]),
              },
            },
          },
          {
            name: "超标率",
            type: "bar",
            barWidth: 20,
            stack: "1",
            data: Object.values(this.water).map((item) => item.exceed * 100),
            itemStyle: {
              normal: {
                color: new this.$echarts.graphic.LinearGradient(0, 1, 1, 0, [
                  {
                    offset: 0,
                    color: "#ef9887",
                  },
                  {
                    offset: 1,
                    color: "#FF8282",
                  },
                ]),
              },
            },
          },
        ],
      };
      myChart.setOption(option);
    },
    //打开全屏
    openDetailChart(option) {
      this.detailChartVisible = true;
      this.$nextTick(() => {
        this.detailChart = this.$echarts.init(
          document.getElementById("deatailChart")
        );
        this.initDeatailChart(option);
      });
    },
    //设置全屏图表
    initDeatailChart(option) {
      let chartOption = {
        xAxis: {
          type: "category",
          data: option.xAxis.data,
        },
        yAxis: {
          type: "value",
        },
        series: option.series,
        title: {
          left: "center",
          text: option.title.text,
        },
        show: true,
        toolbox: {
          feature: {
            dataZoom: {
              yAxisIndex: false,
            },
            saveAsImage: {
              pixelRatio: 2,
            },
          },
        },
      };
      this.detailChart.setOption(chartOption);
    },
    /**
     * 日均分析值
     *  */
    showTypeAction() {
      this.submitSearch();
    },
    //图表获取数据
    async submitSearch(pageOption = { pageSize: this.pageSize, pageNum: 1 }) {
      this.hisLoading = true;
      let params = {
        starttime: this.timePickerDay[0] + " 00:00:00",
        lasttime: this.timePickerDay[1] + " 23:59:59",
        waterstation: this.searchForm.watersmeantation,
        isExcel: "no",
      };
      if (this.mintype === "图表") {
        await meanRate(params).then((res) => {
          if (res.data) {
            // this.searchResult = [];
            // this.meanRate = res.data.avgDatas;
            // this.configLineChart();
            // let res = await getHistoricalData(params);
            this.searchResult = res.data;
            this.configLineChart();
          }
        });
      } else if (this.mintype === "表格") {
        await meanRate({ ...params, ...pageOption }).then((res) => {
          if (res.data) {
            this.totalpage = res.data.totalpage;
            this.avgDatas = [];
            this.factorField = [];
            res.data.avgDatas.push(res.data.min);
            res.data.avgDatas.push(res.data.max);
            res.data.avgDatas.push(res.data.avg);

            this.$nextTick().then(() => {
              this.avgDatas = res.data.avgDatas;
              res.data.factorMessage.forEach((item) => {
                if (Object.keys(res.data.factorField).includes(item.name)) {
                  this.standard[res.data.factorField[item.name]] =
                    item.standardValue;
                  this.factorField.push({
                    prop: res.data.factorField[item.name],
                    label: item.name + (item.name === "pH" ? "" : " mg/L"),
                    devStatus: item.name,
                    standardValue: item.standardValue,
                    factorLimit:
                      item.name === "pH"
                        ? "±" + item.factorLimit + "L"
                        : item.factorLimit + "L",
                  });
                }
              });
              this.factorStatus = res.data.factorStatus;
            });
          }
        });
      }
      this.hisLoading = false;
    },
    configLineChart() {
      let chartData = this.searchResult.avgDatas || [];
      let newOptions = {};
      let translate = {};
      let standard = {};
      let lineOptions = {};
      this.searchResult.factorMessage.forEach((item, index) => {
        if (this.searchResult.factorField[item.name]) {
          translate[this.searchResult.factorField[item.name]] = item.name;
          standard[this.searchResult.factorField[item.name]] =
            item.standardValue;
          newOptions[this.searchResult.factorField[item.name]] = new Array();
          lineOptions[this.searchResult.factorField[item.name]] = {};
        }
        if (this.searchResult.factorMessage.length - 1 === index) {
          newOptions["xAxis"] = new Array();
        }
      });
      for (let i = 0, len = chartData.length; i < len; i++) {
        for (var key in newOptions) {
          if (key !== "xAxis") {
            newOptions[key].push(chartData[i][key]);
          } else {
            newOptions[key].push(chartData[i].gmtMonitor);
          }
        }
      }
      let defaultOption = {
        show: true,
        grid: {
          left: "11%",
        },
        title: {
          // text: 'pH/总磷',
          left: "center",
          top: 10,
          textStyle: {
            fontSize: 14,
          },
        },
        tooltip: {
          trigger: "axis",
        },
        xAxis: {
          // data: newOptions.xAxis,
          type: "category",
          axisLabel: {
            formatter: (value) => value.replace(/ /, "\n"),
          },
          axisTick: {
            inside: true,
            alignWithLabel: true,
          },
        },
        yAxis: {
          name: "mg/L",
          splitLine: {
            show: false,
          },
          axisTick: {
            inside: true,
          },
        },
        series: [
          {
            type: "line",
            stact: "总量",
            smooth: true,
            large: true,
            data: newOptions.ph,
            areaStyle: {},
            itemStyle: {},
          },
        ],
      };

      let optionColor = {
        ph: "#A3A6F6",
        COD: "#F47FC1",
        ammoniaNitrogen: "#5BB0F0",
        phosphorus: "#FF8282",
        nitrogen: "#F0D65B",
        nickel: "#67EBAB",
        cuprum: "#F09C5B",
        chromium: "#5DD3EC",
        prussiate: "#D4A3F6",
        zinc: "#5BF0E6",
      };
      this.$nextTick(() => {
        for (let i in lineOptions) {
          lineOptions[i] = common.deepClone(defaultOption);
          lineOptions[i].series[0].itemStyle.color = optionColor[i];
          lineOptions[i].series[0].areaStyle = {
            color: new this.$echarts.graphic.LinearGradient(0, 0, 0, 1, [
              {
                offset: 0,
                color: optionColor[i],
              },
              {
                offset: 1,
                color: "rgb(255, 255, 255)",
              },
            ]),
          };
          lineOptions[i].title.text = translate[i];
          lineOptions[i].xAxis.data = newOptions.xAxis.reverse();
          lineOptions[i].series[0].data = newOptions[i].reverse();
          lineOptions[i].series[0].name = translate[i];
          lineOptions[i].series[0].markLine = {
            name: translate[i],
            silent: true,
            large: true,
            symbol: "none",
            data: [
              {
                yAxis: standard[i],
              },
            ],
            label: {
              position: "end",
              // formatter: '标准线:{c}'
            },
            lineStyle: {
              color: "#e46f6f",
            },
          };

          lineOptions[i].show =
            newOptions[i].filter((d) => d !== null).length > 0;
        }

        // ph special handle
        if (lineOptions["ph"]) {
          lineOptions["ph"].yAxis.max = 14; //ph
          lineOptions["ph"].yAxis.maxInterval = 2;
          lineOptions["ph"].yAxis.name = "";
          lineOptions["ph"].series[0].markLine.data = [
            {
              yAxis: standard["ph"].split("~")[1],
            },
            {
              yAxis: standard["ph"].split("~")[0],
            },
          ];
        }
        this.isMeanNoData = Object.values(lineOptions)
          .map((v) => v.show)
          .includes(true);
        this.lineOptions = lineOptions;
      });
    },
    //表格配置
    tableRowStyle({ rowIndex }) {
      if (rowIndex % 2 > 0) {
        return {
          backgroundColor: "#f6f6f6",
        };
      } else {
        return {
          backgroundColor: "#fff",
        };
      }
    },
    // 分页
    // pageUpdate(option) {
    //   this.submitSearch(option);
    // },
    //设置条数
    setNum(val) {
      this.pageSize = val;
      this.submitSearch({ pageSize: this.pageSize, pageNum: this.currentPage });
    },
    //设置页数
    setPage(val) {
      this.currentPage = val;
      this.submitSearch({ pageSize: this.pageSize, pageNum: this.currentPage });
    },
    openExportOption() {
      this.exportExcelVisible = true;
    },
    async exportExcel() {
      const message = this.$message({
        message: "正在导出数据, 请稍后",
        duration: 0,
      });
      var params = {
        starttime: this.timePickerDay[0] + " 00:00:00",
        lasttime: this.timePickerDay[1] + " 23:59:59",
        waterstation: this.searchForm.watersmeantation,
        isExcel: "yes",
      };
      this.searchForm.isExcel = "yes";
      await meanRateDownload(params).then((res) => {
      });
      this.searchForm.isExcel = "no";
      // await this.submitSearch()
      message.close();
    },
  },
};
</script>

<style scoped>
.upload-demo {
  display: flex;
}

.el-dialog__footer {
  display: flex;
  justify-content: center;
}

.newTest {
  /* background: #fff; */
  min-height: 100%;
  /* padding: 0 20px 0 20px; */
}

.newTest .title {
  position: relative;
  line-height: 70px;
  font-size: 16px;
  background: #ffffff;
  margin-bottom: 20px;
  padding-left: 30px;
}

.newTest .title::before {
  content: "";
  position: absolute;
  left: 15px;
  width: 4px;
  height: 20px;
  top: 25px;
  background-color: #2399ff;
}

.searchBox {
  padding: 20px 0px 0;
  margin-bottom: 20px;
  background-color: #fff;
  display: flex;
}

.searchBox .miniLabel {
  line-height: 0;
}

.searchBtns {
  margin-top: 19px;
}

.el-dialog {
  z-index: 3000 !important;
}
.noData {
  width: 100%;
  line-height: 60px;
  text-align: center;
  color: #909399;
}
/* 因子 */
.dataChartCnt {
  background-color: #fff;
  padding: 0 20px;
}

.dataChartBox {
  display: flex;
  flex-flow: row wrap;
  /* justify-content: space-between; */
  justify-content: flex-start;
  width: 100%;
}

.dataChartBox .chart {
  position: relative;
  width: 31%;
  margin: 0 1%;
  height: 300px;
  min-height: 300px;
  background: #fff;
  margin-bottom: 20px;
}

.dataChartBox .chart .openchart {
  position: absolute;
  right: 12px;
  top: 12px;
  z-index: 1;
}

.deatailChartCnt {
  width: 100%;
  height: 450px;
}

.deatailChartCnt .deatailChart {
  width: 100%;
  height: 100%;
}

.evaluation {
  width: 100%;
  height: 100%;
}

/* 水质分析 */
.qualityEvaluationMini .title {
  line-height: 40px;
  font-size: 14px;
  color: #0063ed;
}

.qualityEvaluationMini .qualityAnalysisSearch {
  padding-bottom: 12px;
}

.qualityEvaluationMini .evaluationCard {
  padding: 8px 8px 0;
  margin-bottom: 8px;
  box-shadow: 1px 1px 5px 0px rgba(75, 75, 75, 0.2);
  background-color: #fff;
}

.evaluationCard .cardTit {
  position: relative;
  padding-left: 8px;
  font-size: 14px;
  line-height: 28px;
  color: #535353;
}

.evaluationCard .cardTit::before {
  content: "";
  position: absolute;
  width: 2px;
  height: 16px;
  background: #0063ed;
  top: 50%;
  margin-top: -8px;
  left: 0;
}

.evaluationCard .chartBox {
  width: 100%;
  height: 200px;
}

.factorTable .el-dialog__body {
  padding-top: 0;
}

.factorTable .el-dialog__header {
  background-image: none;
  height: 20px;
  padding: 0;
}

.factorTable .el-dialog__headerbtn .el-dialog__close {
  color: #666;
}

.loadingText .el-loading-spinner .circular {
  height: 30px;
  width: 30px;
}
/* 日均分析值 */
.showType {
  background-color: #fff;
  padding: 16px;
  /* border-bottom: 1px solid #eee; */
}
.tableList {
  background: #fff;
}
</style>
